
<?php 

class Executor extends CI_Controller {

	
    function __construct(){
    parent::__construct();
    
         
        // load helper
        $this->load->helper('url');
         
        // load model
		$this->load->model('Executor_model');
    }
  /* The default function that gets called when visiting the page */
  public function index() {     
  
  
  }
  
  public function retrieve(){
	$queryExec = $this->input->post('query');
	if(strlen($queryExec)>0){
	$response = $this->executor_model->execute($queryExec)->result_array();
	$this->output->set_content_type('application/json')->set_output(json_encode($response));
	}else{
		show_404();
	}
  }
  public function test(){
	
	$response = "Connection Successful";
	$this->output->set_content_type('application/json')->set_output(json_encode($response));
	
  }
  public function update(){
	$queryExec = $this->input->post('query');
	if(strlen($queryExec)>0){
	$response = $this->executor_model->execute($queryExec);
	$this->output->set_content_type('application/json')->set_output(json_encode($response));
	}else{
		show_404();
	}
  }
  
  // function decryptRJ256($key,$iv,$string_to_decrypt)
	// {
 
	// $string_to_decrypt = base64_decode($string_to_decrypt);
 
	// $rtn = mcrypt_decrypt(MCRYPT_RIJNDAEL_256, $key, $string_to_decrypt, MCRYPT_MODE_CBC, $iv);
 
	// $rtn = rtrim($rtn, "\4");
 
	// return($rtn);
 
	// }
 
	// function encryptRJ256($key,$iv,$string_to_encrypt)
	// {
	 
	// $rtn = mcrypt_encrypt(MCRYPT_RIJNDAEL_256, $key, $string_to_encrypt, MCRYPT_MODE_CBC, $iv);
	 
	// $rtn = base64_encode($rtn);
	 
	// return($rtn);
			
	// }
  
  
}
?>